package com.lanou3g.hw0412;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/4/10;
 * Otherwise, I don't know who created it either
 */

public class OperatorFactory {
    // 根据 操作符( + - * / )
    // 来生成 指定的 计算类
    // 工厂模式
    public static Operator getOperator(String op) {
        Operator operator = null;
        switch (op) {
            case "+":
                operator = new OpAdd();
                break;
            case "-":
                operator = new OpSub();
                break;
            case "*":
                operator = new OpMultiply();
                break;
            case "/":
                operator = new OpDiv();
                break;
            case "^":
                operator = new OpPower();
                break;

        }
        return operator;
    }


}
